import 'package:floor/floor.dart';
import 'package:share_fit/app/models/base_model.dart';

mixin DaoMixin<T extends BaseModel> {
  Future<List<T>> findAll();

  Stream<List<T>> findAllAsStream(); // 流式返回

  Stream<T?> findById(int id);

  @insert
  Future<void> insertOne(T item);

  @insert
  Future<List<int>> insertBatch(List<T> data);

  @update
  Future<int> updateBatch(List<T> data);

  @update
  Future<int> updateOne(T data);

  @delete
  Future<int> deleteBatch(List<T> data);

  @delete
  Future<int> deleteOne(T data);

  Future<void> deleteAll();

  Future<void> deleteAllByAddress(String address);
}
